//
//  FrequentlyQuestionModel.m
//  quxiangtao
//
//  Created by xbmios on 2018/9/29.
//  Copyright © 2018年 shanhaijin. All rights reserved.
//

#import "FrequentlyQuestionModel.h"

@implementation FrequentlyQuestionModel

+ (void)questionModelWithPage:(NSInteger)page success:(HttpRequestSuccess)successBlock fail:(HttpRequestFailed)failblock {
    
    NSString *par = [NSString stringWithFormat:@"{\"page\" : \"%@\", \"number\" : \"%@\"}", [RSA encryptString:[NSString stringWithFormat:@"%ld", page] publicKey:PublicKey], [RSA encryptString:@"10" publicKey:PublicKey]];
    
    [PPNetworkHelper POST:@"user/Helpcenter/Helplist" parameters:@{@"json" : par} success:^(id responseObject) {
        
        NSLog(@"常见问题%@", responseObject);
        
        NSArray *dictArr = responseObject[@"data"];
        
        NSMutableDictionary *d = [NSMutableDictionary dictionaryWithDictionary:responseObject];
        
        if (dictArr.count > 0) {
            
            // 转模型数组
            NSArray *modelArr = [FrequentlyQuestionModel mj_objectArrayWithKeyValuesArray:dictArr];
            
            [d removeObjectForKey:@"data"];
            [d setObject:modelArr forKey:@"data"];
        }
        
        if (successBlock) {
            
            successBlock(d);
            
        }

    } failure:^(NSError *error) {
        
        if (failblock) {
            
            failblock(error);
        }
        
    }];
    
}

@end
